<div id="upload-box">
	<h2><?php echo lang('files.upload_title'); ?><span class="close ui-icon ui-icon-closethick"><?php echo lang('buttons.close'); ?></span></h2>
	<?php echo form_open_multipart('admin/wysiwyg/upload'); ?>
		<?php echo form_hidden('type', 'i'); ?>
		<?php echo form_hidden('redirect_to', 'image'); ?>
		<p>
			<?php echo form_input('name', set_value('name', lang('files.name_label'))); ?>
			<?php echo form_upload('userfile'); ?>
		</p>
		<p>
			<?php echo form_dropdown('folder_id', array(0 => lang('files.dropdown_no_subfolders')) + $libraries_tree); ?>
		</p>
		<p>
			<?php echo form_submit('button_action', lang('buttons.save'), 'class="button"'); ?>
		</p>
	<?php echo form_close(); ?>
</div>
<div id="files_browser">
	<div id="files_left_pane">
		<h3><?php echo lang('file_folders.folders_label'); ?></h3>
		<ul id="files-nav">
		<?php foreach ($libraries as $library): ?>
		<?php if ( ! $library->parent): ?>
			<li id="folder-id-<?php echo $library->id; ?>" class="<?php echo $current_library && $current_library->id == $library->id ? 'current' : ''; ?>">
				<?php echo anchor("admin/wysiwyg/image_popup/index/{$library->id}", $library->title, 'title="'.$library->slug.'"'); ?>
			</li>
		<?php endif; ?>
		<?php endforeach; ?>
		<?php if ($libraries): ?>
			<li class="upload">
				<?php echo anchor("admin/wysiwyg/image_popup/#upload", lang('files.upload_title'), 'title="upload"'); ?>
			</li>
		<?php endif; ?>
		</ul>
	</div>
	<div id="files_right_pane">
		<div id="files-wrapper">
		<?php if ($current_library): ?>
			<h3><?php echo $current_library->title; ?></h3>
			<!-- subfolders -->
			<div id="files_toolbar">
				<ul>
					<li>
						<label for="folder"><?php echo lang('libraries.subfolders_label'); ?>:</label>
						<?php echo form_dropdown('parent_id', $sublibraries, $current_library->id, 'id="parent_id" title="image"'); ?>
					</li>
				</ul>
			</div>
			<!-- image align -->
			<div id="radio-group">
				<label for="insert_float"><?php echo lang('wysiwyg.label.float'); ?></label>
				<div class="set">
					<input id="radio_left" type="radio" name="insert_float" value="left" />
					<label for="radio_left"><?php echo lang('wysiwyg.label.left'); ?></label>
					<input id="radio_right" type="radio" name="insert_float" value="right" />
					<label for="radio_right"><?php echo lang('wysiwyg.label.right'); ?></label>
					<input id="radio_none" type="radio" name="insert_float" value="none" checked="checked" />
					<label for="radio_none"><?php echo lang('wysiwyg.label.none'); ?></label>
				</div>
			</div>
			<!-- folder contents -->
			<?php  if ($current_library->items): ?>
					<?php foreach ($current_library->items as $image): ?>
					<div class="image_popup<?php echo alternator('', ' alt'); ?>">
						<td class="image"><img class="pyro-image" src="<?php echo base_url(); ?>libs/thumb/<?php echo $image->id; ?>/50/50" alt="<?php echo $image->name; ?>" width="50" onclick="javascript:insertThumbnail('<?php echo $image->id; ?>', '<?php echo htmlentities($image->name); ?>');" /></div>
					<?php endforeach; ?>
				</tbody>
			</table>
			<?php else: ?>
			<p><?php echo lang('files.no_files'); ?></p>
			<?php endif; ?>
		<?php else: ?>
			<div class="blank-slate file-folders">
				<h2><?php echo lang('file_folders.no_folders');?></h2>
			</div>
		<?php endif; ?>
		</div>
	</div>
</div>